<template>
	<view class="personalinformation">
		<view class="personalinformation-con">
			<view class="camera" @click="changeAvatar">
				<image src="../../static/my/tx.png" mode=""></image>
			</view>
			<view class="nickname" @click="NicknameModification()">
				<view class="nickname-con">
					<text class="n-name">昵称</text>
					<text class="u-name">{{nickname}}</text>
				</view>
				<image src="../../static/fan.png" mode=""></image>
			</view>
			<view class="nickname" @click="ChangePhoneNumber()">
				<view class="nickname-con">
					<text class="n-name">手机号</text>
					<text class="u-name">{{phonenumber}}</text>
				</view>
				<image src="../../static/fan.png" mode=""></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				nickname: '用户昵称',
				phonenumber: '12345678901'
			}
		},
		methods: {
			changeAvatar() {
				uni.showActionSheet({
					// itemList按钮的文字接受的是数组
					itemList: ["查看头像", "从相册选择图片"],
					success(e) {
						var index = e.tapIndex
						if (index === 0) {
							// 用户点击了预览当前图片
							// 可以自己实现当前头像链接的读取
							let url = "../../static/my/tx.png"
							let arr = []
							arr.push(url)
							uni.previewImage({
								// 预览功能图片也必须是数组的
								urls: arr
							})
						} else if (index === 1) {
							// 用户点击了从图库上传
							uni.chooseImage({
								count: 1,
								sizeType: ["compressed"],
								success(response) {
									// 选择图片后, 返回的数据
									var headI = response.tempFilePaths[0]
									uni.navigateTo({
										// 跳转到图片处理页面,并将图片地址通过参数传递过去
										url: "/components/my/usermsg?headI=" + headI
									})
								}
							})
						}
					}
				})
			},
			NicknameModification() {
				uni.navigateTo({
					url: '/pages/setting/see-details'
				})
			},
			ChangePhoneNumber() {
				uni.navigateTo({
					url: '/pages/setting/resiphone'
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #FFFFFF;
	}

	.personalinformation {
		padding: 0 30rpx;
		background-color: #FFFFFF;

		.personalinformation-con {
			width: 100%;
			height: 100%;

			.camera {
				padding: 85rpx 0;
				display: flex;
				align-items: center;
				justify-content: center;
				margin: auto;
				overflow: hidden;

				image {
					width: 144rpx;
					height: 144rpx;
					display: block;
				}
			}

			.nickname {
				padding: 37rpx 0;
				border-bottom: 1rpx solid #EDEDED;
				display: flex;
				align-items: center;

				.nickname-con {
					width: 100%;
					display: flex;
					align-items: flex-end;
					justify-content: space-between;

					.n-name {
						font-size: 28rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: rgba(142, 142, 142, 1);
					}

					.u-name {
						margin-right: 10rpx;
						font-size: 28rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: rgba(40, 40, 40, 1);
					}
				}

				image {
					width: 12rpx;
					height: 20rpx;
				}
			}
		}
	}
</style>
